package com.atguigu.crowd.util;

import java.util.HashSet;
import java.util.Set;

/**
 * @author yzt
 * @create 2021-09-23 15:59
 */
public class AccessPassResources {

    public static final Set<String> PASS_RES_SET = new HashSet<>();

    static {
        PASS_RES_SET.add("/");
        PASS_RES_SET.add("/auth/member/send/short/message");
        PASS_RES_SET.add("/auth/do/member/register");
        PASS_RES_SET.add("/auth/member/do/login");
        PASS_RES_SET.add("/auth/member/to/logout");
        PASS_RES_SET.add("/auth/member/to/reg/page");
        PASS_RES_SET.add("/auth/member/to/login/page");
    }

    public static Set<String> STATIC_RES_SET = new HashSet<>();

    static {
        STATIC_RES_SET.add("bootstrap");
        STATIC_RES_SET.add("css");
        STATIC_RES_SET.add("fonts");
        STATIC_RES_SET.add("img");
        STATIC_RES_SET.add("jquery");
        STATIC_RES_SET.add("layer");
        STATIC_RES_SET.add("script");
        STATIC_RES_SET.add("ztree");
    }

    public static boolean judgeAccessStaticResources(String servletPath) {
        if (servletPath == null || servletPath.length() == 0) {
            throw new RuntimeException("访问错误！");
        }
        String[] split = servletPath.split("/");
        if (STATIC_RES_SET.contains(split[1])) {
            return true;
        }
        return false;
    }
}
